The present invention relates to a media drive that transfers write data or read data between the media drive and a host according to a command, and to a command processing method thereof. In particular, the present invention relates to a media drive that stores a plurality of commands in a queue to efficiently perform transfer between the media drive and a host, and to a command processing method thereof.
Devices using various types of media such as optical disks and magnetic tapes are known as information recording and reproducing devices. Among them, hard disk drives (hereinafter referred to as “HDD”) have become popular as storage devices for computers to such an extent that they are one of the storage devices indispensable for today's computer systems. Further, not limited to computers, their application is widening more and more due to the superior characteristics with the advent of moving picture recording/reproducing devices, car navigation systems, removable memories for digital cameras and so on.
Almost all of HDDs, which are built into personal computers (PC) excluding servers and some workstations, adopt ATA (AT Attachment) or IDE (Integrated Drive Electronics) interface. In addition, as a result of the improvement in performance, and the increase in capacity, of the ATA interface, because costs of both a drive and a controller are low as compared with costs when SCSI (small computer system interface) is adopted, even entry servers adopt ATA as a hard disk interface in recent years. It is to be desired that a further improvement in performance be achieved without losing advantages of ATA, one of which is very low cost in contrast to the expensive SCSI interface.
As one method for achieving the improvement in performance, it is conceivable that the exchange of data between a HDD and a host is speeded up, that is, an interface is speeded up. There are two methods for speeding up the interface: one is that the number of signal lines is increased so as to increase the amount of data that can be transferred in one cycle; and the other is that a cycle of transferring data is shortened so that the larger amount of data can be transferred during unit time.
Between the two methods, the parallel ATA intended to achieve the speedup by shortening a transfer cycle. However, in order to achieve further speedup, it is necessary to extend the data width, or to increase a frequency of a strobe signal. However, if further speedup is tried, it becomes difficult to maintain synchronization of data between signal lines. Additionally, when a frequency of a signal increases, a problem arises in that the interference between signal lines and noises cannot be ignored. A device is adopted in which a ground line is located between the signal lines so as to make it possible to prevent the interference between the signal lines from occurring, which results in stable transfer. However, with the object of solving the problems, cables and connectors need to be changed to a large extent, and specifications of circuits for transmitting and receiving a signal also need to be changed. For example, a differential signal, the voltage of which is decreased, must be adopted. As a result, the low cost advantage of the ATA interface is lost.
For this reason, in order to achieve the speedup with the manufacturing cost being kept substantially the same as that of the ATA, a serial transmission method is proposed. Serial transmission has a feature that is advantageous to speedup. More specifically, as compared with parallel transmission, the number of signal lines dramatically decreases, and accordingly less interference occurs between signal lines as compared with the parallel transmission. The standards of this serial ATA are being defined by Serial ATA Working Group, constituted of, for example, main hard disk vendors, for the purpose of changing the physical interface of ATA from the conventional parallel interface (parallel ATA) to a high-speed serial interface.
Incidentally, when data is read/written from/to a HDD, the operation requiring the longest period of time is mechanical operation inside the HDD, including the moving time of a head, and rotational latency of a disk. What is required is, therefore, not only an improvement in transfer rate, but also a reduction in the period of time required for read and write.
While electric processing, such as transmitting/receiving a command, decoding, and accessing a memory, is completed in microsecond (μs) order, the mechanical operation inside the HDD requires a long period of time of millisecond (ms) order. The mechanical operation inside the HDD is constituted of the head moving time and the rotational latency. The head moving time denotes a period of time (the seek time) taken from the issuance of a read/write instruction by the HDD until a head is positioned at a target track on a disk. Because this seek time is largely influenced by the moving distance between tracks, the average seek time obtained by dividing the seek time moving from the innermost track to the outermost track by 2 is usually used as a performance indicator.
The rotational latency denotes the waiting time from when the head is moved to a track until the head arrives at a target sector in the track as a result of the rotation of the disk. It is to be noted that although the amount of rotation of the disk differs to a large extent depending on a position of the last sector, a maximum value of the rotational latency is uniquely determined by the rotational speed of the disk. For example, when the rotational speed is 5400 rpm, the maximum value is 11.1 ms; when the rotational speed is 7200 rpm, the maximum value is 8.3 ms; when the rotational speed is 10000 rpm, the maximum value is 6 ms; and when the rotational speed is 15000 rpm, the maximum value is 4 ms.
“Command Queuing” is provided to avoid overhead caused by such mechanical operation to the utmost. The Command Queuing successively issues a plurality of commands without waiting for the completion of command execution, and stores the commands in a queue just as they are. This makes it possible to successively transmit the commands to the HDD without waiting for, on a command basis, the completion of the mechanical operation of the HDD, which requires a long period of time.
In the Command Queuing, instead of executing the commands, which are stored in the queue, according to the order in which the commands have been received (in order), the plurality of commands stored in the queue are rearranged in the efficient order before the commands are executed. The commands are executed by, what is called, out of order. The efficient order is the order that can shorten the distance between tracks so that the move of the head can be shortened as much as possible, and that can shorten the distance between sectors so that the rotational latency becomes short. To be more specific, it is the order that can shorten the mechanical operation of the HDD by shortening the sum of the seek time and the rotational latency. This technique is, what is called, Rotational Positioning Ordering (hereinafter referred to as “RPO”).
In recent years, the seek time is shortened as much as possible not only by paying attention to the positional relationship between tracks, but also paying attention to the positional relationship between sectors and the closest head position. It is because the rotational latency may increase depending on the positional relationship between sectors in some cases. Accordingly, with the object of avoiding such an increase in rotational latency, what is being adopted is a method in which commands are rearranged so that the sum of the seek time and the rotational latency can be shortened as a whole to realize the command execution order in efficient combination with other commands.
In addition, with the object of quickly executing write and read commands to process data, for example, if the top and the end of logical block addresses (Logical Block Address: LBA) of read data read out from a hard disk by a read command agree with or overlap the corresponding ones of another read command, these read commands are integrated so that the commands are executed at a time. This is how to efficiently handle the commands (see, e.g., patent document 1 (Japanese Patent Laid-Open No. 2001-209500)).
Incidentally, also in the “Serial ATA II: Extensions to Serial ATA 1.0a” (hereinafter referred to as “Serial ATAII”), which is already released, a command queuing technology called NCQ (Native Command Queuing) is adopted. The NCQ permits a HDD itself to internally determine the execution order of commands that are queued. This makes it possible to effectively reduce the sum of the seek time and the rotational latency, which are caused by the mechanical internal operation of the HDD.
The NCQ is a function designed taking over the way of thinking of the “Tagged Command Queuing” which the SCSI has. The NCQ has the following three functions:
1. Race-free Status Return Mechanism
2. Interrupt Aggregation
3. First Party DMA (FPDMA).
The “Race-free Status Return Mechanism” is a mechanism by which even when any kind of command is being executed, or at any timing, a status can be freely returned from a drive (usually, a HDD) to, for example, a host controller such as a PC. Additionally, for a response to the status, a handshake with the host does not occur at all. Accordingly, the drive can successively transmit, to the host controller, execution completion statuses of a plurality of commands.
The “Interrupt Aggregation” is a function of suppressing the occurrence of an interruption by integrating, into one, interruptions occurring in a plurality of commands. Next, the “First Party DMA” is a function that allows the drive to set up the DMA (Direct Memory Access) operation for data transfer without the intervention of driver software on the host controller side. The Serial ATA is provided with FIS called DMA Setup FIS, by which the drive selects DMA context on the host controller side. The FIS (Frame Information Structure) is a structure of a frame that is a basic transfer unit of the Serial ATA.
The DMA Setup FIS stores information including tag numbers (0-31) corresponding to commands for which the DMA setup is performed, and the amount of data (DMA Transfer Count) transferred to the host controller. The host controller carries out the DMA transfer processing on the basis of the DMA Setup FIS received from the drive.